var Observer = 
{
	isAttached : false,
	onHttpRequest : null,
	
  	observe: function(subject, topic, data)
	{
		switch (topic)
		{
			case 'http-on-modify-request': 
		    	var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
		    	//httpChannel.setRequestHeader("X-Hello", "World", false);
		    	this.onHttpRequest(httpChannel);
		    	break;
	    	case 'quit-application-granted':
	    		this.unregister();
	    		break;
		}
	  },

  	getObserverService : function()
	{
    	return Components.classes['@mozilla.org/observer-service;1']
                     .getService(Components.interfaces.nsIObserverService);
  	},

  	register: function()
  	{
    	this.getObserverService().addObserver(this, 'http-on-modify-request', false);
    	this.getObserverService().addObserver(this, 'quit-application-granted', false);
    	
    	this.isAttached = true;
  	},

  	unregister: function()
  	{
    	this.observerService.removeObserver(this, 'http-on-modify-request');
    	this.isAttached = false;
  	}
}